package com.rsk.api;


import com.alibaba.dubbo.config.annotation.Reference;
import com.rsk.api.common.ReturnUtils;
import com.rsk.service.SysCompanyTracksService;
import com.rsk.service.SysCompanyTypesService;
import com.rsk.service.SysCompanysService;
import com.rsk.utils.result.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.ws.rs.QueryParam;
import java.time.DateTimeException;
import java.util.Date;

/**
 * 机构跟踪
 * @author myr
 */

@RestController
@RequestMapping(value="/sys/companytracks")
public class SysCompanyTracksApi {

    @Reference(interfaceClass = SysCompanysService.class, protocol = "dubbo")
    private SysCompanyTracksService sysCompanyTracksService;


    /**
     * 删除机构跟踪
     * @param id
     * @param Authorization
     * @return
     */
    //@RequiresPermissions("sys_users:save")
    @PostMapping(value="/delSysCompanyTracks" )
    public Result<String> delSysCompanyTracks(@QueryParam("id") Long id,
                                         @RequestHeader("Authorization") String Authorization){
        //String operatorUser = JwtUtil.getClaim(Authorization, "account");
        Long operatorUser = 123L;
        int i = sysCompanyTracksService.delSysCompanyTracks(id, operatorUser);
        return ReturnUtils.returnDataByOne(i);
    }


    /**
     * 新增机构跟踪
     * @param id
     * @param companyId 机构Id
     * @param trackTheme 跟踪主题
     * @param trackContent  跟踪内容
     * @param trackTime   跟踪时间
     * @param contactsUser  联系人
     * @param contactsPhone  联系人电话
     * @param userId  负责人
     * @param Authorization
     * @return
     */
    //@RequiresPermissions("sys_users:save")
    @PostMapping(value="/saveSysCompanyTracks")
    public Result<String> saveSysCompanyTracks(@QueryParam("id") Long id,
                                              @QueryParam("companyId") Long companyId,
                                              @QueryParam("trackTheme") String trackTheme,
                                              @QueryParam("trackContent")  String trackContent,
                                              @QueryParam("trackTime") Date trackTime,
                                              @QueryParam("contactsUser") String contactsUser,
                                              @QueryParam("contactsPhone") String contactsPhone,
                                              @QueryParam("userId")  Long userId,
                                              @RequestHeader("Authorization") String Authorization){
        //String operatorUser = JwtUtil.getClaim(Authorization, "account");
        Long operatorUser = 123L;
        int i = sysCompanyTracksService.saveSysCompanyTracks(id,companyId,trackTheme,trackContent,trackTime,
                contactsUser,contactsPhone,userId,operatorUser);
        return ReturnUtils.returnDataByOne(i);
    }
}
